package org.jbox2d.testbed.tests;

import org.jbox2d.collision.shapes.CircleDef;
import org.jbox2d.collision.shapes.PolygonDef;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.testbed.AbstractExample;
import org.jbox2d.testbed.TestbedMain;

public class Test3 extends AbstractExample {
	
	public Test3(TestbedMain parent){
		super(parent);
	}
	
	@Override
	public void create() {
		PolygonDef groundBoxDef = new PolygonDef();
		groundBoxDef.setAsBox(50.0f, 0.0f);
		groundBoxDef.density = 0.0f;
 
		BodyDef groundBodyDef = new BodyDef();
		groundBodyDef.position.set(-.0f, -10.0f);
		m_world.createBody(groundBodyDef).createShape(groundBoxDef);
 
 
//		PolygonDef pd=new PolygonDef();
//		pd.setAsBox(40.f,0.1f);
//		BodyDef bdf = new BodyDef();
//		bdf.position.set(-30.0f, 0.0f);
//		bdf.angle=(float)Math.PI/2;
//		m_world.createStaticBody(bdf).createShape(pd);
//		
//		
//		BodyDef bdf2 = new BodyDef();
//		bdf2.position.set(30.0f, 0.0f);
//		bdf2.angle=(float)Math.PI/2;
//		m_world.createStaticBody(bdf2).createShape(pd);
//		
//		
//		BodyDef bdf3 = new BodyDef();
//		bdf3.position.set(0.0f, 33.0f);
//		bdf3.angle=(float)Math.PI;
//		m_world.createStaticBody(bdf3).createShape(pd);
 
		CircleDef[] cds=new CircleDef[30];
		for(int i=0;i<cds.length;i++){
			cds[i]=new CircleDef();
			cds[i].density = 1.0f;//-i*0.1f;
			cds[i].friction = 0.3f;
			cds[i].restitution=0.05F*i;
			BodyDef bd=new BodyDef();
			bd.position.set(-30.f+i*2.2f,30.f);
			bd.isBullet=false;
			Body b=m_world.createBody(bd);
			b.createShape(cds[i]);
			b.setMassFromShapes();
		}
 
//		myImage = parent.loadImage("noise.png");
//
//		Vec2 localOffset = new Vec2(0.0f, 0f);
//
//		float scale = 1.9f / myImage.width;
//
//		float rot = 0f;
//		bindImage(myImage, localOffset, rot, scale, box);
	}

	@Override
	public String getName(){
		return "Test3";
	}
	
}
